if not integerp(theCast) and not stringp(theCast) then
exit
end if
if the castType of cast theCast <> #text then
exit
end if
if not (the number of chars in field theCast) then
exit
end if
if not integerp(autoAppend) then
set autoAppend to 0
end if
set styleList to BuildStyleList(theCast)
repeat with cnt = 1 to count(styleList)
set styleRun to getAt(styleList, cnt)
obj(mSetTextFont, getaProp(styleRun, #font))
obj(mSetTextSize, getaProp(styleRun, #size))
obj(mSetTextStyle, getaProp(styleRun, #style))
set charsAdded to obj(mAppendText, char getaProp(styleRun, #start) to getaProp(styleRun, #end) of field theCast, autoAppend)
if charsAdded = 0 then
exit
end if
end repeat
end
on BuildStyleList theCast
if the castType of cast theCast <> #text then
return []
end if
if not (the number of chars in field theCast) then
return []
end if
set styleList to []
set curFont to EMPTY
set curSize to 0
set curStyle to EMPTY
repeat with cnt = 1 to the number of chars in field theCast
if (the textFont of char cnt of cast theCast <> curFont) or (the textSize of char cnt of cast theCast <> curSize) or (the textStyle of char cnt of cast theCast <> curStyle) then